#include <bits/stdc++.h>

using namespace std;

class Solution
{
public:
    string decodeMessage(string key, string message)
    {
        int n = message.size(), count = 0;

        unordered_map<char, int> key_map;

        for (auto &ch : key)
        {
            if (ch == ' ')
            {
                continue;
            }

            if (!key_map.count(ch))
            {
                key_map.insert({ch, count++});
            }
        }

        for (int i = 0; i < n; i++)
        {
            if (message[i] == ' ')
            {
                continue;
            }
            message[i] = 'a' + key_map[message[i]];
        }

        return message;
    }
};
